<template>
  <div>
    <div id="nightingaleRose" ref="nightingaleRose" style="height:458px;margin-bottom:16px;"></div>
  </div>
</template>

<script>
import echarts from 'echarts'
export default {
  name: 'NightingaleRose',
  data () {
    return {
      mychart: {}
    }
  },
  mounted () {
    this.initChart()
    window.addEventListener('resize', () => {
      setTimeout(() => {
        this.mychart.resize()
      }, 500)
    })
  },
  methods: {
    initChart () {
      this.mychart = echarts.init(this.$refs.nightingaleRose)
      const option = {
        backgroundColor: 'rgb(12,16,61)',
        title: {
          text: '本级行政区域面积数',
          left: 16,
          top: 16,
          textStyle: {
            color: '#fff',
            fontSize: 14,
            fontWeight: 'normal'
          }
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        series: [
          {
            name: '面积模式',
            type: 'pie',
            radius: [10, 110],
            center: ['50%', '55%'],
            roseType: 'area',
            data: [
              { value: 10, name: '刘家堡乡' },
              { value: 5, name: '坞城街道' },
              { value: 15, name: '营盘街道' },
              { value: 25, name: '西温庄' },
              { value: 20, name: '北格镇' },
              { value: 35, name: '北营街道' },
              { value: 30, name: '小店街道' }
            ]
          }
        ]
      }
      this.mychart.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped></style>
